import { Window } from "../../../component/window/Window";
import { ImgTxt } from "../task/imgtxt/ImgTxt";
import { LayerManager } from "../../manager/LayerManager";
import { Global } from "../../../../com/gengine/global/Global";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItem } from "../common/BaseItem";
import { SWFInfo } from "../../../../com/gengine/resource/info/SWFInfo";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWedding } from "../../../../Message/Public/SWedding";
import { MarryWeddingConfig } from "../../resource/MarryWeddingConfig";
import { MarryHeartLock } from "./defin/MarryHeartLock";
import { AIManager } from "../../scene/ai/AIManager";
import { Cache } from "../../cache/Cache";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { AIType } from "../../scene/ai/AIType";
import { GButton } from "../../../../com/mui/controls/GButton";
//class MarryBookingSuccessWindow
    
    export  class MarryBookingSuccessWindow extends Window
    {
        constructor()
        {
            super();
            this._imgTxt = new ImgTxt();
            this.layer = LayerManager.windowLayer;
            return;
        }

        /* internal  */positionToCenter(): void
        {
            this.x = (Global.stage.stageWidth - 416) / 2;
            this.y = (Global.stage.stageHeight - 344) / 2 - 50;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var textFormatDes: Object /* flash.text.TextFormat */;
            var textFormat: Object /* flash.text.TextFormat */;

            var loc1;
            super.createChildren();
            this._bg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bg);
            textFormatDes = GlobalStyle.textFormat1;
            textFormatDes.leading = 8;
            this._tfDes = ObjCreate.createTextField("", 83, 110, 260, 60, this, textFormatDes);
            this._tfDes.multiline = true;
            this._tfDes.wordWrap = true;
            this._tfDes.mouseWheelEnabled = false;
            this._tfDes.htmlText = "";
            textFormat = GlobalStyle.textFormat6;
            textFormat.size = 14;
            this._tfReward = ObjCreate.createTextField(Language.getString(43568), 100, 172, 75, 20, this, textFormat);
            this._tfRewardContent = ObjCreate.createTextField("", 174, 172, 150, 20, this);
            this._itemBg = GlobalClass.getBitmap(ImagesConst.PackItemBg);
            this._itemBg.x = 180;
            this._itemBg.y = 192;
            this.addChild(this._itemBg);
            this._baseItem = new BaseItem();
            this._baseItem.x = 183;
            this._baseItem.y = 195;
            this._baseItem.setSize(32, 32);
            this.addChild(this._baseItem);
            this._btnOK = ObjCreate.createGButton(Language.getString(43611), 165, 234, 70, 26, this, "ButtonLarge");
            this._btnOK.addEventListener(flash.events.MouseEvent.CLICK, this.onClickOK);
            this._tfDes.addEventListener(flash.events.TextEvent.LINK, this.onLink);
            with ({}) 
            {
            };
            "FlowersBg.swf".load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onLoaded = (arg1: SWFInfo): void
            {
                _bg.bitmapData = arg1.bitmapData;
                _bg.width = 416;
                _bg.height = 344;
                positionToCenter();
                return;
            })
            return;
        }

        /* internal  */onClickOK(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryNPCInviteGuests, false));
            this.hide();
            return;
        }

        public updateData(arg1: SWedding): void
        {
            var loc4=null;
            var loc1=MarryWeddingConfig.instance.getWeddingByType(arg1.weddingType);
            this._tfDes.htmlText = Language.getStringByParam(43570, arg1.man.name, loc1.name, arg1.weddingDt.hours.toString(), loc1.guest.toString());
            this._tfRewardContent.htmlText = MarryHeartLock.getHeartLockHtml(arg1.weddingType) + " <font color=\'#FFFFFF\'>（邮件发放）</font>";
            this._baseItem.itemData = MarryHeartLock.getHeartLockItemData(arg1.weddingType);
            this.addChild(this._imgTxt);
            this._imgTxt.x = 0;
            this._imgTxt.y = -3;
            var loc2=this._imgTxt.bulidPic("fly", 0, this._tfDes, "FlyBoot_upSkin", false, 1);
            loc2 = 0;
            var loc3=this._imgTxt.numChildren;
            while (loc2 < loc3) 
            {
                (loc4 = this._imgTxt.getChildAt(loc2) as Object /* flash.display.Sprite */).addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
                ++loc2;
            }
            return;
        }

        /* internal  */onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAIControl(Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectMarryRegister), AIType.AI_Convey);
            return;
        }

        /* internal  */onLink(arg1: Object /* flash.events.TextEvent */): void
        {
            AIManager.onAutoPathAIControl(Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectMarryRegister));
            return;
        }

        protected /* override */ updateBtnSize(): void
        {
            if (_closeBtn) 
            {
                _closeBtn.x = 320;
                _closeBtn.y = 10;
            }
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_imgTxt: ImgTxt;

        /* internal */ /* var */_tfDes: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfReward: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfRewardContent: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_btnOK: GButton;
    }
